import { createTable, listTable } from "@/app/appcommon/api/tool/gen2";
import { dateRange, loading, queryParams, tableList, total ,visible} from "./data";
import { addDateRange } from "@/utils/ruoyi";
import { ElDialog, ElMessage, ElMessageBox } from "element-plus";
import gen_table from "./gen_table"
import gen_table_column from "./gen_table_column"
/** 查询表集合 */
function getList() {
    loading.value = true;
    tableList.value = [];
    total.value = 0;    
    listTable(addDateRange(queryParams.value, dateRange.value)).then(
      (response) => {
        console.log({ response })
        tableList.value = response.rows;
        total.value = response.total;
        loading.value = false;
      }
    ).catch((error)=>{
      console.log(error.message)
      console.log(queryParams.value)
      loading.value = false;
      if(error.message.includes("Table") && error.message.includes("doesn't exist")) {
        ElMessage.error('表gen_table不存在，请到数据源管理页面创建')
      }
    });
  }
function updateDsNameToParams(item){
  Object.assign(queryParams.value.params, { dsName: item });
}
  export {
    getList,
    updateDsNameToParams
  }